package svgedit.TestSVG;

import static org.junit.Assert.assertTrue;
import org.junit.Test;
import svgedit.gui.Frame;
import svgedit.svg.SVGDocument;
import svgedit.svg.SVGLineElement;
import svgedit.svg.SVGPaint;
import svgundoredo.PaintElementCommand;

/**
 * test PaintElementCommand class
 */

public class PaintElementCommandTest
{
    
    /**
     * test execute() method
     */
    @Test
    public void testexecute()
    {
        // create new paint
        SVGPaint paint = new SVGPaint();
        paint.setPaint(1, "c", "blue", "black");
        int type = 0;
        int t2 = 1;
        Frame frame = new Frame();
        SVGDocument document;
        document = frame.getDocument();
        SVGLineElement element = new SVGLineElement(document);
        PaintElementCommand p = new PaintElementCommand(element, paint, type);
        // test the paint with type "0"
        p.execute();
        assertTrue(element.getFill().getPaintType() == 1);
        assertTrue(element.getStroke().getPaintType() == 101);
        PaintElementCommand p2 = new PaintElementCommand(element, paint, t2);
        // test the paint with type "1"
        p2.execute();
        assertTrue(element.getFill().getPaintType() == 1);
        assertTrue(element.getStroke().getPaintType() == 1);
        
    }
}
